class Logistic < ActiveRecord::Base
  has_many   :orders
  has_many   :logistic_fees
  before_save :convert_province_array

  attr_accessor :province_array,:fee


  def convert_province_array
    return if !province_array
    province_array.values.each do |i|
      LogisticFee.delete_all(["province_id = ?",i])
      LogisticFee.create(:province_id=>i,
        :logistic_id=>self.id,
        :fee=>fee) if i!="0"
    end
  end
end
